<template>
  <div class="rich-text-viewer" v-html="content"></div>
</template>

<script setup>
const props = defineProps({
  content: {
    type: String,
    default: ''
  }
})
</script>

<style scoped>
.rich-text-viewer {
  padding: 16px;
  border: 1px solid #e4e7ed;
  border-radius: 4px;
  background-color: #fafafa;
  min-height: 100px;
  line-height: 1.6;
}

/* 富文本内容样式 */
.rich-text-viewer :deep(h1),
.rich-text-viewer :deep(h2),
.rich-text-viewer :deep(h3),
.rich-text-viewer :deep(h4),
.rich-text-viewer :deep(h5),
.rich-text-viewer :deep(h6) {
  margin: 16px 0 8px 0;
  font-weight: bold;
}

.rich-text-viewer :deep(p) {
  margin: 8px 0;
}

.rich-text-viewer :deep(ul),
.rich-text-viewer :deep(ol) {
  margin: 8px 0;
  padding-left: 24px;
}

.rich-text-viewer :deep(li) {
  margin: 4px 0;
}

.rich-text-viewer :deep(blockquote) {
  margin: 16px 0;
  padding: 8px 16px;
  border-left: 4px solid #409eff;
  background-color: #f4f4f5;
}

.rich-text-viewer :deep(table) {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
}

.rich-text-viewer :deep(table th),
.rich-text-viewer :deep(table td) {
  border: 1px solid #dcdfe6;
  padding: 8px;
  text-align: left;
}

.rich-text-viewer :deep(table th) {
  background-color: #f5f7fa;
  font-weight: bold;
}

.rich-text-viewer :deep(code) {
  background-color: #f4f4f5;
  padding: 2px 4px;
  border-radius: 2px;
  font-family: 'Courier New', monospace;
}

.rich-text-viewer :deep(pre) {
  background-color: #f4f4f5;
  padding: 12px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 16px 0;
}

.rich-text-viewer :deep(img) {
  max-width: 100%;
  height: auto;
  margin: 8px 0;
}

.rich-text-viewer :deep(strong) {
  font-weight: bold;
}

.rich-text-viewer :deep(em) {
  font-style: italic;
}

.rich-text-viewer :deep(u) {
  text-decoration: underline;
}

.rich-text-viewer :deep(s) {
  text-decoration: line-through;
}
</style>
